package com.algo.core.processor;

import com.algo.core.HttpRequestWrapper;
import com.algo.core.RequestContext;
import com.algo.core.filter.RapidFilterChain;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.DefaultFullHttpResponse;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.util.ReferenceCountUtil;

import java.util.Date;

/**
 * 将请求封装成一个具体的任务
 */
public class RequestTask implements Runnable {

    private HttpRequestWrapper httpRequestWrapper;

    private RapidFilterChain filterChain;

    public RequestTask(HttpRequestWrapper httpRequestWrapper, RapidFilterChain filterChain) {
        this.httpRequestWrapper = httpRequestWrapper;
        this.filterChain = filterChain;
    }

    @Override
    public void run() {
        // 这里应该去执行过滤器链的逻辑了
        RequestContext requestContext = new RequestContext();
        requestContext.setHttpRequestWrapper(httpRequestWrapper);
        filterChain.doFilter(requestContext);
    }

}
